<?php
namespace app\home\model;

use think\Model;

class Tool extends Model
{
	public function getList($where = ['is_show' => 1], $field = '*'){
        return $this->where($where)->field($field)->select();
	}

	/* 获取器 */
	// 工具类型
	public function getTidAttr($val){
        return (new Tool_type)->getFind(['id' => $val], 'name, color');
    }

    // 添加时间
    public function getAddTimeAttr($val){
        if(!$val){
            return '';
        }

        $nowYear = date('Y', time());
        $oldYear = date('Y', $val);

        if($nowYear == $oldYear){
            return date('m-d H:i:s', $val);
        }else{
            return date('Y-m-d', $val);
        }
    }
}